﻿Imports System.Windows.Forms

Public Class frmDateRange
    Public Mindate As String
    Private m_BaseSoruce As CAermod.BaseSource  '污染源基类
    Property BaseSource() As CAermod.BaseSource
        Get
            Return Me.m_BaseSoruce
        End Get
        Set(ByVal value As CAermod.BaseSource)
            Me.m_BaseSoruce = value
        End Set
    End Property

    Private m_StartTime As String = ""
    Private m_EndTime As String = ""

    Property StartTime() As String
        Get
            Return Me.m_StartTime
        End Get
        Set(ByVal value As String)
            Me.m_StartTime = value
        End Set
    End Property
    Property EndTime() As String
        Get
            Return Me.m_EndTime
        End Get
        Set(ByVal value As String)
            Me.m_EndTime = value
        End Set
    End Property


    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Dim TimeEnd As Date = "2008年" + DateTimeEnd.Text
        Dim TimeStart As Date = "2008年" + DateTimeStart.Text
        If TimeEnd < TimeStart Then
            MessageBox.Show("结束时间小于开始时间，请重新检查您输入的数据!")
            Me.Activate()
        Else
            Me.StartTime = Me.DateTimeStart.Text
            Me.EndTime = Me.DateTimeEnd.Text
            Me.DialogResult = System.Windows.Forms.DialogResult.OK
            Me.Close()
        End If
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub
    '判断时间段设置
    Private Sub DateRange_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Leave
        If DateTimeEnd.Value < DateTimeStart.Value Then
            MessageBox.Show("结束时间小于开始时间，请重新检查您输入的数据!")
            Me.Activate()
        End If
        If Mindate <> "" Then
            If DateTimeStart.Value < Mindate Then
                MessageBox.Show("开始时间不能与已设置排放时段重合，请重新检查您输入的数据!")
                Me.Activate()
            End If
        End If
        

    End Sub
    ''' <summary>
    ''' 根据污染源类型 设置表格
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub DateRange_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.SourcePolluent.Styles.Alternate.BackColor = Color.FromArgb(216, 228, 248)
        'Me.DateTimeStart.Text = "2028年01月01日00时"
        'Me.DateTimeEnd.Text = "2028年12月31日23时"



        Me.SourcePolluent.Cols.Count = 3


        If m_BaseSoruce.Location.Srcid.Substring(0, 1) <> "P" Then
            Me.SourcePolluent.SetData(0, 2, "排放速率(g/s-m^2)")
            Label2.Visible = False
            Label5.Visible = False

            temp.Visible = False
            Esit.Visible = False
        Else
            Me.SourcePolluent.SetData(0, 2, "排放速率(g/s)")
        End If

        '设置污染物表格
        If m_BaseSoruce.PollutionPara IsNot Nothing Then

            Me.SourcePolluent.Rows.Count = m_BaseSoruce.PollutionPara.Length + 1
       
            '设置表格
            For i As Integer = 0 To m_BaseSoruce.PollutionPara.Length - 1
                Me.SourcePolluent.SetData(i + 1, 0, m_BaseSoruce.PollutionPara(i).Name) '污染物名称
                Me.SourcePolluent.SetData(i + 1, 1, 0)
            Next

        End If

        Me.SourcePolluent.AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
        Me.SourcePolluent.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.None
        Me.SourcePolluent.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None
    End Sub

    Private Sub DateTimeEnd_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimeEnd.ValueChanged

    End Sub
End Class
